<%var csstpl = {%>
<link rel="stylesheet" href="${basepath}/plugin/ztree/css/zTreeStyle/metro.css" />
<%};%>
<%var jstpl = {%>
	    <script src="${basepath}/plugin/ztree/jquery.ztree.all-3.5.min.js"></script>
	    <script>
	    var zNodes =${json!}
	    var setting = {
				check: {
					enable: true
				},
				data: {
					simpleData: {
						enable: true
					}
				},   callback:{
	                onCheck:onCheck
	            }
			};
	    
		
		$(document).ready(function(){
			$.fn.zTree.init($("#role_ztree"), setting, zNodes);
			onCheck();
		});
		
		 function onCheck(e,treeId,treeNode){
			 	var treeObj=$.fn.zTree.getZTreeObj("role_ztree"),
	            nodes=treeObj.getCheckedNodes(true),
	            v="";
	            for(var i=0;i<nodes.length;i++){
	            v+=nodes[i].id + ",";
	            //alert(nodes[i].id); //获取选中节点的值
	            }
	            $("#roilelist").val(v);
	            }

		 
		 var form = layui.form;
		 form.verify({
			 isengletter:function(value,item){
				 if(!new RegExp("^[a-zA-Z]+$").test(value)){
				      return '权限组代码只能为英文字母';
				 }
		 	}
		 })
		 
		 
	    </script>
<%};%>
<%layout("../layout/_layout_layui.html",{title:'添加/修改角色权限',jstpl:jstpl,csstpl:csstpl}){ %>
<div class="layui-row" id="content">
   <section>
		<!-- 内容开始 -->
		<div class="">
		    <form id="test_validate" role="form"  method="post" action="/system/role/manage/save_role/" class="layui-form">
                                            <input type="hidden" name="role.id" value="${role.id!}">
                                            
                                          			<div class="layui-form-item">
                                                    <label class="layui-form-label" for="input04">权限名称</label>
                                                    <div class="layui-input-block">
                                                        <input class="layui-input" value="${role.name!}" name="role.name"  lay-verify="required"  placeholder="请输入权限名称" id="input04" type="text">
                                                    </div>
                                                </div>
                                                
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label" for="">权限代码</label>
                                                    <div class="layui-input-block">
                                                        <input class="layui-input" value="${role.role_code!}" name="role.role_code"  lay-verify="required|isengletter"  placeholder="请输入权限组代码(英文字母)" id="" type="text">
                                                    </div>
                                                </div>
                                                
                                                
                                                 
                                          		<div class="layui-form-item layui-form-text">
                                                    <label class="layui-form-label"  for="input05">描述信息</label>
                                                    <div class="layui-input-block">
                                                        <textarea class="layui-textarea"  name="role.des" lay-verify="required"  placeholder="请输入描述信息" id="input05" rows="3">${role.des!}</textarea>
                                                    </div>
                                                </div>
                                                
                                          		<div class="layui-form-item">
                                                    <label class="layui-form-label">排序</label>
                                                    <div class="layui-input-block">
                                                     <input class="layui-input" name="role.sort" value="${role.sort!}"  lay-verify="required|number"  placeholder="排序" id="input04" type="text">
                                                     <input class="span6" name="roilelist"  id="roilelist" type="hidden">
                                                    </div>
                                                </div>
                                                
                                          			<div class="layui-form-item">
                                                    <label class="layui-form-label" for="">权限功能</label>
                                                    <div class="layui-input-block">
                                                    <div class="ztree  "  id="role_ztree"></div>
                                                    </div>
                                                </div>
                                            
                                
                                                <div class="layui-form-item">
                                                      <div class="layui-input-block">
                                                    <button class="layui-btn" lay-submit lay-filter="formDemo"  >保存</button>
                                                    <button type="button" onclick="window.history.back()" class="layui-btn layui-btn-primary">返回</button>
                                                    </div>
                                                </div>
       											
                                            </form>
		
		</div>
		<!-- 内容end -->
</section>
</div>
<%}%>